package com.sf.fy.uav.order.controller;

import com.alibaba.fastjson.JSONObject;
import com.sf.fy.uav.common.request.common.IdRequest;
import com.sf.fy.uav.common.request.pricing.PricingAddRequest;
import com.sf.fy.uav.common.request.pricing.PricingEditRequest;
import com.sf.fy.uav.common.request.pricing.SysPricingRequest;
import com.sf.fy.uav.common.response.order.ProductTypeResp;
import com.sf.fy.uav.common.response.order.SysPricingResponse;
import com.sf.fy.uav.common.utils.Rs;
import com.sf.fy.uav.order.entity.Pricing;
import com.sf.fy.uav.order.service.IPricingService;
import com.sf.fy.uav.service.IProductTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.math.BigDecimal;
import java.util.List;

/**
 * <p>
 * 计价表 前端控制器
 * </p>
 *
 * @author LTQ
 * @since 2023-05-19
 */
@RestController
public class PricingRest {

    @Autowired
    private IPricingService iPricingService;
    @Autowired
    private IProductTypeService productTypeService;

    public Pricing getPrice(String takeoffCode, String landingCode, Integer seconds) {
        return iPricingService.getPrice(takeoffCode, landingCode, seconds);
    }

    public Pricing getPriceByProductType(Byte productType, Integer seconds) {
        return iPricingService.getPriceByProductType(productType, seconds);
    }

    public List<Pricing> getPriceByProductTypes(List<Byte> productTypes, Integer seconds) {
        return iPricingService.getPriceByProductTypes(productTypes, seconds);
    }


    public List<Pricing> getByProductTypes(List<Byte> productTypes) {
        return iPricingService.getByProductTypes(productTypes);
    }

    public JSONObject calculateMarkup(double goodsWeight, BigDecimal jl, String pricingId, BigDecimal price) {
        return iPricingService.calculateMarkup(goodsWeight, jl, pricingId, price);
    }

    public List<SysPricingResponse> getPricing(SysPricingRequest sysPricingRequest) {
        return iPricingService.getPricing(sysPricingRequest);
    }

    public Long getTotal(SysPricingRequest sysPricingRequest) {
        return iPricingService.getTotal(sysPricingRequest);
    }

    public void add(PricingAddRequest pricingAddRequest) {
        iPricingService.add(pricingAddRequest);
    }

    public void edit(PricingEditRequest pricingEditRequest) {
        iPricingService.edit(pricingEditRequest);
    }

    public void disablePricing(@RequestBody IdRequest idRequest) {
        iPricingService.disablePricing(idRequest);
    }

    public List<ProductTypeResp> getProductType() {
        return productTypeService.getProductType();
    }
}
